package com.lmt.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.ctc.wstx.util.ExceptionUtil;
import com.lmt.block.BlockHandlerDemo;
import com.lmt.entity.User;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: TODO
 * @Author: Amazing
 * @Date: 2022/8/1 14:52
 * @Version: 1.0
 */
@RestController
@RefreshScope // 刷新配置文件
public class UserController {

    @Value("${temp.notify}")
    private String notify;

    @GetMapping("/getUserById/{id}")
    @SentinelResource(value = "user", blockHandler = "exceptionHandler", blockHandlerClass = BlockHandlerDemo.class)
    public User getUserById(@PathVariable Long id) {
        return User.builder().id(id).name("我也不知道").intro(notify).build();
    }
}
